#根据 Dog 类创建的每个实例都将存储名字和年龄。我们赋予了每条小狗蹲下（ sit() ）和打滚
#（ roll_over() ）的能力：

from Car import Car

class Dog():
    """一次模拟小狗的简单尝试"""
    def __init__(self, name, age):
        """初始化属性name和age"""
        self.dogName = name         # 属性dogName
        self.dogAge = age           # 属性dogAge
    def sit(self):
        """模拟小狗被命令时蹲下"""
        print(self.dogName.title() + " is now sitting.")
    def roll_over(self):
        """模拟小狗被命令时打滚"""
        print(self.dogName.title() + " rolled over!")

mydog = Dog('xiaoBai',5)
print('my dog\'s name is :'+mydog.dogName.title()+'.')
print('my dog is '+str(mydog.dogAge)+' years old.')
mydog.roll_over()
mydog.sit()

class ElectricCar(Car):
    """电动汽车的独特之处"""
    def __init__(self, make, model, year):
        """
        电动汽车的独特之处
        初始化父类的属性，再初始化电动汽车特有的属性
        """
        super().__init__(make, model, year)# super() 是一个特殊函数，帮助Python将父类和子类关联起来       
        self.battery_size = 70
    def describe_battery(self):
            """打印一条描述电瓶容量的消息"""
            print("This car has a " + str(self.battery_size) + "-kWh battery.")    
    def overrideFunTest(self):
            """子类对父类方法的重写测试"""
            print('我是ElectricCar类的方法,我重写了父类中的方法')

my_tesla = ElectricCar('tesla', 'model s', 2016)
print(my_tesla.get_descriptive_name())
my_tesla.describe_battery()
my_tesla.overrideFunTest()